package summative;

import java.util.*;

public class VectorList
{
  
  ArrayList <Vector> vectors;
  ViewPanel panel;
  VectorFocusList fList;
  ViewList vList;
  Menu menu;
  MenuItemList list;
  public VectorList(ViewList viewList, VectorFocusList fList, Menu menu, MenuItemList list)
  {
    vectors = new ArrayList <Vector> ();
    this.list = list;
    this.fList = fList;
    this.vList = viewList;
    this.menu = menu;
    this.menu.setVectorList(this);
    //panel.setVectorList(this);
    list.setVectorList(this);
    //this.panel = panel;
    //this.menu = menu;
    
  }
  
  public void addVector(String string)
  {
    try
    {
      Vector vectorB = new Vector(string);
      vectors.add(vectorB);
      fList.addVector(vectorB);
      list.addJMenuItem();
    }catch(NumberFormatException e)
    {
      System.out.println("Incorrect input: please try again");
    }
    
    vList.update(1);
  }
  
  public ArrayList <Vector> getArray()
  {
    return vectors;
  }
  
  public Vector getVector(int number)
  {
    return vectors.get(number);
  }
  
  public void addVector(int x, int y, int xF, int yF, Boolean mouseListener)
  {
	  try
	    {
	      Vector vectorB = new Vector(x, y, xF, yF, mouseListener);
	      vectors.add(vectorB);
	      fList.addVector(vectorB);
	      list.addJMenuItem();
	    }catch(NumberFormatException e)
	    {
	      System.out.println("Incorrect Input: Try again");
	    }

	    
	    vList.update(1);
  }
  public void additionVectors()
  {
	  Vector output = VectorCalculations.addVector(fList.getVector(0), fList.getVector(1));
	  addVector(output.getUnitVec());
  }
  
  public void subtractionVectors()
  {
	  Vector output = VectorCalculations.subtractVector(fList.getVector(0), fList.getVector(1));
	  addVector(output.getUnitVec());
  }
  
  public void dotProductVectors()
  {
	  double output = VectorCalculations.dpVector(fList.getVector(0), fList.getVector(1));
  }
}